<template>	        
	<view class='main'>
		<navbar  :btnColors='btnColor' :bgColor="bgColor" title="分享中心" :isGoBack="true" :isNotice="true" :visible="true"></navbar>
		
           <view class="share_top">			   
			   	<image class="mine__bg--avatar" style="background:" :src="userInfo.wx_icon?userInfo.wx_icon:'/static/mine/avatar.png'" @click="setBase()"></image>	
				
				<view class="mt-20 mr-20" @click="share_poster()" >
					<u-button text="分享推广" shape="circle" type="primary"   size="small" color="#36B3E9 " class="ml-20" customStyle="width:150rpx;height:65rpx" ></u-button>
				</view>
			  
           	
           </view>
			
			<view class="margin-top">
				   <view class="flex margin-one">
				   	    <view class="flex flex-direction money1">
				   	   	   <text style="font-size: 26rpx;">我的团员</text>
						   <text style="font-size: 48rpx;margin-top: 20rpx;">{{userInfo.share_num}}</text>
				   	    </view>
					    <view class="flex flex-direction money1">
					   	   <text style="font-size: 26rpx;">累计单数</text>
					   		<text style="font-size: 48rpx;margin-top: 20rpx;">{{userInfo.groups_order}}</text>
					    </view>
				   </view>			
						 
					
					<view class="flex margin-one justify-between" style="margin-top: 80rpx;;">
						<view class="flex flex-direction money1">
						   <text style="font-size: 26rpx;">累计收益（元）</text>
						   <text style="font-size: 48rpx;margin-top: 20rpx;">{{userInfo.groups_money}}</text>
						</view>
						<view class="flex flex-direction money1" style="margin-right: -40px;">
						 <view class="cash_botton" @click="docash()">
						 	 <text class="cash_text">申请提现</text>
						 </view>
						</view>
					</view>					
			</view>
				
			
		
		<view class="list">					
			<view class="node-tab">
				<view class="tab-item"  :class="[currentTab == 1 ? 'active' : '']" :data-current="1" @click="changeNav">收入记录</view>
				<view class="tab-item"  :class="[currentTab == 2 ? 'active' : '']" :data-current="2" @click="changeNav">提现记录</view>
			</view>	
			
                <swiper class="tab-content"  duration="300" bindchange="changeTab" :style="{'height':winHeight+'px'}">
					<!-- 全部 -->
					<swiper-item>
						<scroll-view :scroll-y="true" class="new-list-box" @scrolltolower="allLoadMore" scroll-top="scrollTop" scroll-with-animation :refresher-enabled="true" refresher-threshold="80" refresher-default-style="white" refresher-background="white" :refresher-triggered="triggered" @refresherrefresh="onAllRefresh">
							<block v-if="allTabList.length > 0">
								<view class="new-list-item border-b" v-for="(item,index) in allTabList" :key="index">                        
									<view class="item-tag dis-flex-between">     
										<view class="content-deadline" style="color: #222222;font-size: 32rpx;">类型：{{item.info}}</view>     
										<view class="content-deadline text-xsl mt-20" style="color: #888888;">交易时间：{{item.add_time}}</view>										                       
									</view>
									<view class="item-tag dis-flex-between" style="text-align: end;">
										
									 <view class="content-deadline text-bold" style="color: #36B3E9;" v-if="item.style==1">+{{item.affectMoney}}</view>
									  <view class="content-deadline text-bold" style="color: red;"  v-if="item.style==0">-{{item.affectMoney}}</view>
									  
									<view class="content-deadline mt-20" style="color: #888888;">{{item.info}}</view>
								  </view>
								</view>
							</block>                
						</scroll-view>
					</swiper-item>       
				</swiper>	
			 
		</view>
	</view>		
</template>
<script>
	export default {		
		data() {
			return {
				...getApp().globalData.config,
				userInfo:{},
				winHeight:0,
				pageNo:1,
				allTabList:[], // 全部  
				currentTab: 1, // 当前所在滑块的 index
				scrollTop: 0, // 设置竖向滚动条位置
				triggered: false, // 下拉是否激活
			};
		},
		onShow(){			
		   this.userInfo=uni.getStorageSync('userInfo')
		},
		onLoad(options){
			let that=this
			if(options.cashType){
			  this.cashType=options.cashType			  
			}
			let height = uni.getSystemInfoSync().windowHeight;
			this.winHeight = (height - 360);			
			this._requestPageList(true);
		},	
		methods:{
			
			//分享推广
			share_poster(){
				this.$routers.router('/pages/pagesuser/share_poster/index','navigateTo') 
			},
			
			//申请提现
			docash(){
				this.$routers.router('/pages/pagesuser/docash_draw/index','navigateTo') 
			},		
			
			//银行卡
			bank_list(){
				this.$routers.router('/pages/pagesuser/bankList/index','navigateTo') 
			},
			changeNav(e){
				let currentIndex = e.target.dataset.current;				
				this.pageNo=1;
				this.currentTab= currentIndex				
				this.allTabList=[];
				this._requestPageList(true);
			},	
			// 参数
			_requestPageList(isLoadMore = false, callback) {
			  if(!isLoadMore){
				this.allTabList=[]; // 全部       
				this.pageNo= 1;
				
			  }
			  let opt = {
				pageNo :this.pageNo,				
				token:uni.getStorageSync('userInfo').token,
				status:this.currentTab
			  }    
			  this._requestPageListCom("virtualTaskList", opt, callback);
			},
			// 列表接口
			_requestPageListCom(url, params, callback) {    
			  this.$http.moneylog_list(params).then(res => {
				if (res.resCode == "9999") {
				  let oldList = [];
				  oldList = this.allTabList;       
				  const newGoodsList = res.data.list
				  const allData = [...oldList, ...newGoodsList]
				  // console.log(allData,'allData')     
				  this.allTabList=allData
				  if(callback && typeof callback === 'function'){
					callback()
				  }
				}
			  })
			},			  
			// 上拉加载  滚动到底部/右边时触发
			allLoadMore(e){
				let _self = this;
				if (this._allLoadMore) return
				this._allLoadMore = true;
				this.pageNo= ++_self.pageNo				
				this._requestPageList(true, () => {
				  _self._allLoadMore = false;
				});
			},
			
			// 下拉刷新接口
			onAllRefresh() {
			 // 开启下拉自定义样式
				this.triggered = true;
			    this.pageNo=1;
				this._requestPageList(false, () => {
					// 当处理完数据刷新后，wx.stopPullDownRefresh可以停止当前页面的下拉刷新
					this.triggered = false;
				});    
			},
			//提现
			docash(){
				this.$routers.router('/pages/pagesuser/docash_draw/index','navigateTo') 
			}
		}
	}
</script>
<style>
	@import "./index.css";
</style>